package com.sg.business.commons.labelprovider.organization;

import java.util.List;

import org.eclipse.jface.viewers.ColumnLabelProvider;

import com.mongodb.DBObject;
import com.sg.business.model.Organization;

public class CompanyCodeLabelProvider extends ColumnLabelProvider {

	@SuppressWarnings("unchecked")
	@Override
	public String getText(Object element) {
		String result = "";
		if (element instanceof Organization) {
			Organization org = (Organization) element;
			List<DBObject> companyCodeList = (List<DBObject>) org
					.getCompanyCode();
			if (companyCodeList != null && companyCodeList.size() > 0) {
				for (DBObject dbo : companyCodeList) {
					String code = (String) dbo.get("code");
					if (result != "") {
						result += ",";
					}
					result += code;
				}
			}
		}
		return result;
	}
}
